#!/usr/bin/env python
# -*- coding: utf-8 -*-
# auth : pangguoping
import pika

# ######################### 生产者 #########################
credentials = pika.PlainCredentials('guest', 'guest')
# 链接rabbit服务器（localhost是本机，如果是其他服务器请修改为ip地址）
connection = pika.BlockingConnection(pika.ConnectionParameters('localhost', 5672, '/', credentials))
channel = connection.channel()
channel.exchange_declare(exchange='hello', type='fanout')
for x in range(1, 10):
    channel.basic_publish(exchange='hello', routing_key='', body='hehe %s' % (x))

connection.close()
